//
//  ViewController.m
//  UI13_Xib创建自定义Cell
//
//  Created by LGC on 16/3/25.
//  Copyright © 2016年 Apon. All rights reserved.
//

#import "ViewController.h"
#import "TableViewOfFilm.h"
#import "CellOfFilm.h"
@interface ViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain)TableViewOfFilm *tableView;

@end

@implementation ViewController

- (void)dealloc {
    [_tableView release];
    [super dealloc];
}

- (void)createTableView {
    self.tableView = [[TableViewOfFilm alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    
    // 注册xib格式的cell
    [self.tableView registerNib:[UINib nibWithNibName:@"CellOfFilm" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"pool"];
    
    [self.view addSubview:self.tableView];
    [_tableView release];
}

#pragma mark - dataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    CellOfFilm *cell = [tableView dequeueReusableCellWithIdentifier:@"pool"];
    
    
    return cell;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTableView];
    self.navigationItem.title = @"Xib自定义创建Cell";    // Do any additional setup after loading the view, typically from a nib.
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 220;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
